//
//  UIButton+AllState.m
//  HealthManager_Customer
//
//  Created by lzh on 2017/12/27.
//  Copyright © 2017年 Facebook. All rights reserved.
//

#import "UIButton+AllState.h"
//用到了UIImage+YYAdd.h
//#import "YYCategories.h"

@implementation UIButton(AllState)

- (void)changeTitle:(NSString*)title
{
    [self setTitle:title forState:UIControlStateNormal];
    [self setTitle:title forState:UIControlStateSelected];
    [self setTitle:title forState:UIControlStateHighlighted];
    [self setTitle:title forState:UIControlStateDisabled];
}

- (void)changeTitleColor:(UIColor*)color
{
    [self setTitleColor:color forState:UIControlStateNormal];
    [self setTitleColor:color forState:UIControlStateSelected];
    [self setTitleColor:color forState:UIControlStateHighlighted];
    [self setTitleColor:color forState:UIControlStateDisabled];
}

- (void)changeBackgroundImage:(UIImage*)image
{
    [self setBackgroundImage:image forState:UIControlStateNormal];
    [self setBackgroundImage:image forState:UIControlStateSelected];
    [self setBackgroundImage:image forState:UIControlStateHighlighted];
    [self setBackgroundImage:image forState:UIControlStateDisabled];

}

- (void)changeImage:(UIImage*)image
{
    [self setImage: image forState:UIControlStateNormal];
    [self setImage: image forState:UIControlStateSelected];
    [self setImage: image forState:UIControlStateHighlighted];
    [self setImage: image forState:UIControlStateDisabled];
}

- (void)changeBackgroundImage:(UIImage *)image selectAlpha:(CGFloat)alpha {
    
    [self setBackgroundImage:image forState:UIControlStateNormal];
    [self setBackgroundImage:[image imageByApplyingAlpha:alpha] forState:UIControlStateSelected];
    [self setBackgroundImage:[image imageByApplyingAlpha:alpha] forState:UIControlStateHighlighted];
    [self setBackgroundImage:[image imageByApplyingAlpha:alpha] forState:UIControlStateDisabled];

}

- (void)changeBackgroundColor:(UIColor *)color selectAlpha:(CGFloat)alpha {

    UIImage *image = [UIImage imageWithColor:color];
    [self changeBackgroundImage:image selectAlpha:alpha];
}
@end
